﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.admin
{
    public partial class Login : System.Web.UI.Page
    {
        private DataClasses1DataContext dc=new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
           

        }



        protected void ImageButtonLogin_Click(object sender, EventArgs e)
        {
            string username = this.userlogin.Value.ToString();
            string password = this.passlogin.Value.ToString();
            AdminLogin ad;

            if (adminlogin(username, password) != null)
            {



                Response.Redirect("home.aspx");


                Labelkiemtra.Text = "Accoun SUCCESS";


            }
            else
            {

                Labelkiemtra.Text = "Account Not found";
            }
        }

        public AdminLogin adminlogin(string username, string password)
        {
            AdminLogin ad = new AdminLogin();
            try
            {

                ad = dc.AdminLogins.Where(am => am.username.Equals(username)).ToList().First();
                Session["admin"] = ad;
            }
            catch
            {
                ad = null;
            }
            return ad;
        }
    }
}